/*
* Copyright (c) 2007 by Kirill Kolodyazhniy.
* See the file "license.terms" for information on usage and redistribution.
*/

#ifndef M_SUBENTITY_H
#define M_SUBENTITY_H

#include "renderable.h"
#include "submesh.h"
#include "weakptr.h"


namespace Engine
{
	class Entity;

	/**
	*   Class implement renderable interface.
	*/
	class SubEntity: public Renderable
	{
	public:

		SubEntity(WeakPtr<SubMesh> subMesh, Entity* parent);

		~SubEntity();

		/**
		*   Retrieves a pointer to the material this renderable object uses.
        */
        virtual const MaterialPtr GetMaterial(void) const;

		/**
		*   Gets the render operation required to send this object to the frame buffer.
        */
		virtual RenderDataPtr GetRenderData() const;

		/**
		*   Gets the world transform matrix / matrices for this renderable object.
        */
        virtual const Matrix4<REAL>& GetWorldTransform() const;

		/**
		*   Returns vertex data.
		*/
		virtual const HardWareBufferPtr GetVertexData() const;

		/**
		*   Returns index data.
		*/
		virtual const HardWareBufferPtr GetIndexData() const;

		/**
		*   Return vertex declaration object.
		*/
		virtual const VertexDeclarationPtr GetVertexDeclaration() const;
	private:

		WeakPtr<SubMesh> m_subMesh;
		Entity* m_parent;
		RefPtr<RenderData, WeakPtrExtension> m_renderData;
	};
}

#endif
